package Hot100;

public class setZeroes {
    public static void main(String[] args) {

    }
    public void setZeroes(int[][] matrix) {
        int n = matrix.length;
        int m = matrix[0].length;
        int[] row = new int[n];//行
        int[] col = new int[m];
        for (int i = 0; i < n; i++) {
            row[i] = 1;
        }
        for (int i = 0; i < m; i++) {
            col[i] = 1;
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(matrix[i][j] == 0){
                    row[i] = 0;
                    col[j] = 0;
                }
            }
        }
        for (int i = 0; i < n; i++) {
            for (int j = 0; j < m; j++) {
                if(row[i] == 0 || col[j] == 0){
                    matrix[i][j] = 0;
                }
            }

        }
    }
}
